package com.fjd.mapper;

import com.fjd.entity.Discount;
import com.fjd.entity.DiscountDetail;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;

@Mapper
public interface DiscountDetailMapper {

    @Select("select min(discount_price) from discount_detail where discount_id = #{discountId}")
    BigDecimal getCheapestPrice(String discountId);


    @Select("select * from discount_detail where product_id = #{productId} and discount_id = #{discountId}")
    DiscountDetail getDiscountPriceByProductIdAndDiscountId(String productId, String discountId);

    @Insert("insert into discount_detail (product_id,discount_price,discount_id) VALUES (#{productId},#{discountPrice},#{discountId})")
    void add(String productId,BigDecimal discountPrice,String discountId);
}
